<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>请假信息页表页</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/color.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.8.8/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.8.8/jquery.easyui.min.js"></script>


</head>
<body>
	<table id="outrequest2_dg" title="请假信息" class="easyui-datagrid"
		style="width: 1150px; height: 480px"
		url="${param.request.contextPath}/outRequest/teacherlist"
		toolbar="outrequest2_toolbar" pagination="true" rownumbers="true"
		fitColumns="true" singleSelect="true">

		<div id="outrequest2_toolbar">
			<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-edit" plain="true" onclick="editOutRequest()">编辑</a>
		</div>

		<thead>
			<tr>
				<th field="cb" checkbox="true" align="center"></th>
				<th field="outId" align="center" align="center">编号</th>
				<th field="stuId" width="30" formatter="stuIdFormatter"
					align="center">学号</th>
				<th field="claId" width="30" formatter="claIdFormatter"
					align="center">班级编号</th>
				<th field="reason" width="50" align="center">请假原因</th>
				<th field="start" width="50" align="center">请假开始时间</th>
				<th field="end" width="50" align="center">请假结束时间</th>
				<th field="name" width="30" formatter="tehIdFormatter"
					align="center">审批人</th>
			</tr>
		</thead>
	</table>


	<div id="outrequest2_dlg" class="easyui-dialog"
		style="width: 500px; height: 320px; padding: 10px 20px" closed="true"
		buttons="#outrequest2_dlg-buttons">
		<form id="outrequest2_fm" enctype="multipart/form-data" method="post">
			<div class="fitem">
				<label>学号:</label> <input id="stuId" name="stuId"
					class="easyui-validatebox" required="true" readonly="readonly">
			</div>
			<div class="fitem">
				<label>班级编号:</label> <input id="claId" name="claId"
					class="easyui-validatebox" required="true" readonly="readonly">
			</div>
			<div class="fitem">
				<label>请假原因:</label>
				<textarea name="reason" rows="" cols="" readonly="readonly"
					style="height: 60px; width: 100%" placeholder="请描述请假原因"></textarea>
			</div>
			<div class="fitem">
				<label>开始时间:</label> <input name="start" class="easyui-datetimebox"
					readonly="readonly">
			</div>
			<div class="fitem">
				<label>结束时间:</label> <input name="end" class="easyui-datetimebox"
					readonly="readonly">
			</div>
			<div class="fitem">
				<label>审批人:</label> <input id="name" name="teacher.tehId">
			</div>
		</form>
	</div>
	<div id="outrequest2_dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
			onclick="saveOutRequest()">保存</a> <a href="#"
			class="easyui-linkbutton" iconCls="icon-cancel"
			onclick="javascript:$('#outrequest2_dlg').dialog('close')">取消</a>
	</div>


	<script type="text/javascript">
		function stuIdFormatter(value, row, index) {
			return row.student.stuId;
		}

		function claIdFormatter(value, row, index) {
			return row.classId.claId;
		}

		function tehIdFormatter(value, row, index) {
			return row.teacher.name;
		}

		function editOutRequest() {
			$('#outrequest2_fm').form('clear');
			var row = $('#outrequest2_dg').datagrid('getSelected');
			$('#stuId').val(row.student.stuId);
			$('#claId').val(row.classId.claId);
			$('#name').val(row.teacher.tehId);
			if (row) {
				$('#outrequest2_dlg').dialog('open')
						.dialog('setTitle', '编辑请假条');
				$('#outrequest2_fm').form('load', row);
				url = '${pageContext.request.contextPath}/outRequest/teacheredit?outId='
						+ row.outId;
			}
		}

		function saveOutRequest() {
			$('#outrequest2_fm').form('submit', {
				url : url,
				onSubmit : function() {
					return $(this).form('validate');
				},
				success : function(result) {
					var result = eval('(' + result + ')');
					if (!result.success) {
						$.messager.show({
							title : '错误信息提示',
							msg : result.errorMsg
						});
					} else {
						$.messager.show({
							title : '成功信息提示',
							msg : result.errorMsg
						});
					}

					$('#outrequest2_dlg').dialog('close');
					$('#outrequest2_dg').datagrid('reload');
				}
			});
		}
	</script>

</body>
</html>